from flask import redirect, url_for, Flask
from flask_sqlalchemy import SQLAlchemy
from config import config
import pymysql

pymysql.install_as_MySQLdb()

db = SQLAlchemy()


def config_modle():
    app = Flask(__name__)
    app.config.from_object(config)
    db.init_app(app)

    @app.errorhandler(404)
    def erro(e):
        # return redirect(url_for('/'))
        return '404'

    from info.index import index_blue
    app.register_blueprint(index_blue)
    from info.news import new_blue
    app.register_blueprint(new_blue)
    from info.desktop import desktop_blue
    app.register_blueprint(desktop_blue)

    return app
